<?php foreach ($modules as $module) { ?>
<?php echo $module; ?>
<?php } ?>

<script type="text/javascript"><!--
$('#menu input[name=\'filter_name\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#button-search').trigger('click');
	}
});

$('#current-conditions input[name=\'filter_name\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#button-search-detail').trigger('click');
	}
});

$('#button-search').bind('click', function() {
	url = 'index.php?route=restaurant/search';
	
	var filter_name = $('#menu input[name=\'filter_name\']').attr('value');
	
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	location = url;
});


$('#button-search-detail').bind('click', function() {
	url = 'index.php?route=restaurant/search';
	
	var filter_name = $('#current-conditions input[name=\'filter_name\']').attr('value');
	
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	var filter_district_id = $('#current-conditions select[name=\'filter_district_id\']').attr('value');
	
	if (filter_district_id) {
		url += '&filter_district_id=' + encodeURIComponent(filter_district_id);
	}
		
	var filter_description = $('input[name=\'filter_description\']:checked').attr('value');

	// Get all additional conditions
	var conditions = "";
	var hiddenEls = $('#current-conditions input[type=\'hidden\']');
	$(hiddenEls).each(function(index) {
		if(conditions.length > 0){
			conditions += ",";
		}
		
		conditions += $(this).val();
	});

	if(conditions.length > 0){
		url += '&filter_option_value_ids=' + conditions;
	}
	
	if (filter_description) {
		url += '&filter_description=true';
	}

	location = url;
});
//-->
</script>